<template>
  <!-- <div class="routerBackContent"> -->
    <div class="app-container home">
    <!-- tab标签 -->
    <el-tabs v-model="activeName">
      <el-tab-pane label="频道搜索" name="1"></el-tab-pane>
      <el-tab-pane label="一键配置" name="2"></el-tab-pane>
    </el-tabs>

    <div v-if="activeName == '2'" >
    <span style="color: red;font-weight: bold;">
    提示:该功能将清除已保存的频道数据，重新搜索，并配置默认频道，请谨慎操作！</span>
    <div style="text-align: center;">

 <!-- <el-form  ref="form1" :model="form1"   size="small" label-width="90px" >
            <el-form-item  label="板卡"  style="margin-bottom: 0px;">
              <div style="align-items: center; display: flex;text-align: center;height: 32px;width: 220px;">
              <el-radio v-model="board" label="1" >板卡1</el-radio>
              <el-radio v-model="board" label="2" >板卡2</el-radio>
              </div>
          </el-form-item>
          </el-form> -->
   <!-- <div>  -->
  <!-- </div> -->
 <!-- <el-button type="primary" @click="clearAgainScanRestart(form1.board)" style="text-align: center;">一键清除，重新配置</el-button>  -->
       <!-- <el-button type="primary" @click="clearAgainScanClick">一键清除，重新配置</el-button> -->
        <!-- <el-button type="primary" @click="clearAgainScanRestart">一键清除，重新配置</el-button>  -->
                <el-button type="primary" @click="clearAgainScanRestart(1)">板卡1一键清除，重新配置</el-button> 
        <el-button type="primary" @click="clearAgainScanRestart(2)">板卡2一键清除，重新配置</el-button> 
      </div>
    </div>
    <div v-if="activeName == '1'">
      <div style="display: flex; height: 260px; padding: 5px 0">
        <el-scrollbar class="right-scrollbar" >
           <el-form  ref="form1" :model="form1"   size="small" label-width="90px" >
            <el-form-item  label="板卡"  style="margin-bottom: 0px;">
              <div style="align-items: center; display: flex;text-align: center;height: 32px;width: 220px;">
              <el-radio v-model="board" label="1" >板卡1</el-radio>
              <el-radio v-model="board" label="2" >板卡2</el-radio>
              </div>
          </el-form-item>
          <!-- <el-form-item  label="卫星频道"  style="margin-bottom: 0px;">
              <div style="align-items: center; display: flex;text-align: center;height: 32px;width: 220px;">
              <el-radio v-model="satelliteType" label="1" >高频头1</el-radio>
              <el-radio v-model="satelliteType" label="2" >高频头2</el-radio>
              </div>
          </el-form-item> -->
          <el-form-item  label="卫星信号源"  style="margin-bottom: 0px;">
            <div class="boxSear">
              <img class="btnImg" src="../../../../static/lastLab.png" @click="changeball('last')">
              <div class="fontShow" style="margin-top: -2px;">{{ balls[ball].name }}</div>
              <img class="btnImg" src="../../../../static/nextLab.png" @click="changeball('next')">
            </div>
          </el-form-item>


          <el-form-item  label="序号" style="margin-bottom: 0px;">
            <div v-if="ball == 0" class="boxSear">
              <img class="btnImg" src="../../../../static/lastLab.png" @click="changeNum('last')">
              <div class="fontShow" style="margin-top: -2px;">{{ numbers[num].name }}</div>
              <img class="btnImg" src="../../../../static/nextLab.png" @click="changeNum('next')">
            </div>
            <div v-if="ball == 1" class="boxSear">
              <img class="btnImg" src="../../../../static/lastLab.png" @click="changeNumB('last')">
              <div class="fontShow" style="margin-top: -2px;">{{ numbersB[numB].name }}</div>
              <img class="btnImg" src="../../../../static/nextLab.png" @click="changeNumB('next')">
            </div>
          </el-form-item>

          <el-form-item  label="频率" style="margin-bottom: 0px;">
          <div class="boxSear">     <div class="fontShowBox" style="  margin-left: 60px;margin-top: -1px;">
            {{ pl }}MHz
          </div>
          </div>
          </el-form-item>


          <el-form-item  label="符号率" style="margin-bottom: 0px;">
          <div class="boxSear">
          <div class="fontShowBox" style="margin-left: 60px;margin-top: -1px;">
            {{ fhl }}ks/s
          </div>
          </div>
          </el-form-item>


          <el-form-item  label="极化方式" style="margin-bottom: 0px;height: 32px;">
              <div class="boxSear">
          <div class="fontShowBox" style="margin-left: 60px;margin-top: -1px;">
            {{ jhfs }}
          </div>
          </div>
          </el-form-item>
          </el-form>
          </el-scrollbar>
      </div>
      <div style="text-align: center;">
        <el-button type="primary" @click="scanWeixing">开始搜索</el-button>
       <el-button type="warning" @click="clearScan">清除频道</el-button>
      </div>
    </div>
    </div>

</template>
<script>
import { Notification, MessageBox, Message, Loading } from 'element-ui'
import { clearAgainScan,m3GetService,listChannelSearch,startChannelScanData,stopChannelScanData,resetProgramDbsData,resetSetPrfData } from "@/api/system/channelSearch";
import { apiClearAgainScanById,startSearchChannel,searchChannel,stopChannel,getChannelInfo,setChannelInfoRestart } from "@/api/system/channelSearchOneRestart";
import { getToken } from "@/utils/auth";
import axios from "axios";
import { getNine, getNineB, getGpts } from '@/api/utils'

export default {
  dicts: ['sys_notice_status', 'sys_notice_type','sys_channel_balls','sys_channel_type'],
  data () {
    return {
      isRequesting: false, // 添加标志位，用于表示是否正在进行请求
      timer: null,
      timers: null,
      flag: true,
      timerScan: null,
      token: '',
      activeName: '1',
      board: '1',
      searchTv: 0,
      balls: [{ name: '中星9号', key: 0 }, { name: '中星9B', key: 1 },],
      ball: 0,
      numbers: [],
      num: 0,
      numbersB: [],
      numB: 0,
      gpts: getGpts(),
      gpt: 0,
      nineHao: getNine(),
      nineHaoB: getNineB(),
      pl: '12020',
      fhl: '28800',
      jhfs: '右旋',
      signalLevel: 0,
      signalQuality: 0,
      signalLevel1: 0,
      signalQuality1: 0,
      satelliteType: '1', // 版卡
      tabledata: [],
      tabledataFrp: [],
      allData: [],
      logData: [],
      tsList: [],
      frpInfo: {},
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      },
      curentTime: '',
      loading: null,
      // 表单参数
      form1: {
        channelBall: "1",
        number : 1,
        frequency: 120,
        symbolRate: 288,
        channelType: "2",
        board: '1',
      },
      form2: {
        channelBall: "2",
        number: 1,
        frequency: 28000,
        symbolRate: 390,
        channelType: "3",
        board: '2',
      },
    }
  },
  watch: {
    numB: function (newval, oldval) {
      console.log('numB 监听值变化', newval, oldval)
      clearInterval(this.timer)
      clearInterval(this.timerScan)
      this.signalLevel = 0
      this.signalQuality = 0
      if (this.ball == 0) {
        for (var obj of this.nineHao) {
          if (obj.key == this.num) {
            this.pl = obj.frequency
            this.fhl = obj.fuhao
            this.jhfs = obj.type
          }
        }
      } else {
        for (var obj of this.nineHaoB) {
          if (obj.key == this.numB) {
            this.pl = obj.frequency
            this.fhl = obj.fuhao
            this.jhfs = obj.type
          }
        }
      }
    },
    num: function (newval, oldval) {
      console.log('num 监听值变化', newval, oldval)
      clearInterval(this.timer)
      clearInterval(this.timerScan)
      this.signalLevel = 0
      this.signalQuality = 0
      if (this.ball == 0) {
        for (var obj of this.nineHao) {
          if (obj.key == this.num) {
            this.pl = obj.frequency
            this.fhl = obj.fuhao
            this.jhfs = obj.type
          }
        }
      } else {
        for (var obj of this.nineHaoB) {
          if (obj.key == this.numB) {
            this.pl = obj.frequency
            this.fhl = obj.fuhao
            this.jhfs = obj.type
          }
        }
      }
    },
    ball: function (newval, oldval) {
      console.log('ball 监听值变化', newval, oldval)
      clearInterval(this.timer)
      clearInterval(this.timerScan)

      this.signalLevel = 0
      this.signalQuality = 0
      if (newval == 0) {
        this.pl = this.nineHao[0].frequency
        this.fhl = this.nineHao[0].fuhao
        this.jhfs = this.nineHao[0].type
      } else {
        this.pl = this.nineHaoB[0].frequency
        this.fhl = this.nineHaoB[0].fuhao
        this.jhfs = this.nineHaoB[0].type
      }
    }
  },
  created() {
    this.getList();
  },
  methods: {

    //一键清空操作,===>先进行登录,将板卡分发的频道清空
    //开始进行搜索==>根据搜索结果判断是否要持续循环搜索
    //直至有搜索结果后,获取所有的最新频道,更新数据库
    //给直播板卡分发默认频道
  clearAgainScanRestart(boardId){
     this.$modal.confirm('确认要一键清空 "直播板卡' + boardId + '" 的频道配置，并重新搜索分发默认频道吗？').then(() => {
        this.loading = this.$loading({
          lock: true,
          text: '正在进行一键配置直播板卡'+boardId+'频道,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
         this.clearAgainScanById({
          "id": boardId,
        },boardId);
      }).catch(() => {
        console.log('用户取消了一键配置操作');
      }).finally(() =>{
          this.loading.close();
          this.loading = null;
      });
    },
    clearAgainScanById(data,boardId){
      // const boardId = data.id;
      console.log("清除频道接口请求参数:"+JSON.stringify(data)+"=========="+boardId);
              this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 正在清空已分发的频道,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      apiClearAgainScanById(data).then(res =>{
        if (res.code == 200) {
            console.log("频道清空完成,开始进行频道搜索");
            this.startSearchChannel(data,boardId);
          } else {
            console.log("频道清空失败");
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          this.loading.close();
          this.loading = null;
      });
    },
        startSearchChannel(data,boardId){
      console.log("启动频道搜索接口请求参数:"+JSON.stringify(data));
              this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 开始启动频道搜索,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        
      startSearchChannel(data).then(res =>{
        if (res.code == 200) {
            console.log("启动频道搜索完成,开始进行频道搜索");
            this.searchChannel(data,boardId);
          } else {
            console.log("启动频道搜索失败");
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          this.loading.close();
          this.loading = null;
      });
    },

    searchChannel(data,boardId){
                  this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 启动搜索频道,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });

          // 先清除可能存在的旧定时器，防止重复执行
      if (this.timerScan) {
        clearInterval(this.timerScan);
        this.timerScan = null;
      }


    // 定义搜索函数，方便复用
  const doSearch = async () => {
                  this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 正在搜索频道,请持续等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });

    try {
      console.log("持续频道搜索接口请求参数:" + JSON.stringify(data));
      const res = await searchChannel(data);
      if (res.code === 200) {
        console.log("持续频道搜索完成,最新搜索结果: " + JSON.stringify(res.data));
        const searchResult = res.data;
        
        // 根据不同结果处理
        if (searchResult === 1) {
          console.log("继续循环搜索中..........");
          // 不需要做额外操作，定时器会继续执行
        } else if (searchResult === 0) {
          console.log("频道搜索圆满完成,清除定时器,调用停止搜索接口");
          this.handleSearchComplete(boardId, data, searchResult, '搜索完成');
        } else {
          console.log("频道搜索过程中出错,清除定时器,调用停止搜索接口");
          this.handleSearchComplete(boardId, data, searchResult, '搜索失败');
        }
      } else {
        console.log("启动频道搜索失败");
        this.$message({ message: res.msg, type: 'error' });
        this.cleanupSearch();
      }
    } catch (error) {
      console.log("频道搜索接口异常:" + error);
      this.$message({ message: '搜索接口异常', type: 'error' });
      this.cleanupSearch();
    }
  };

  // 立即执行一次搜索
  doSearch();
  
  // 设置定时器，每隔1秒执行一次
  this.timerScan = setInterval(doSearch, 2000);
},

    // 处理搜索完成的通用方法
handleSearchComplete(boardId, data, result, statusText) {
  // 更新加载提示
  if(this.loading){
     this.loading.setText(`直播板卡${boardId} ${statusText},请等待...`);
  }else{
       // 如果loading已被关闭，重新创建
    this.loading = this.$loading({
      lock: true,
      text: `直播板卡${boardId} ${statusText},请等待...`,
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    });
  }
  // 清除定时器
  this.cleanupSearch();
  
  // 调用停止搜索接口
  this.stopChannel(data, boardId, result);
},

// 清除搜索相关资源
cleanupSearch() {
  if (this.timerScan) {
    clearInterval(this.timerScan);
    this.timerScan = null;
  }
  if (this.loading) {
    this.loading.close();
    this.loading = null;
  }
},

            stopChannel(data,boardId,searchResult){
      console.log("频道停止接口请求参数:"+JSON.stringify(data));
              this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 正在停止频道搜索,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      stopChannel(data).then(res =>{
        if (res.code == 200) {
            console.log("停止频道搜索完成,判断是否要继续获取搜索到的最新频道,进行默认频道分发:"+searchResult);
            if(searchResult == 0){
              //开始获取最新频道
              console.log("前面持续进行频道搜索,最后一次表示搜索顺利完成,开始获取最新频道信息,进行分发默认频道");
              this.getChannelInfo(data,boardId);
            }else{
              console.log("前面持续进行频道搜索,最后一次搜索失败.不再持续进行搜索");
            }
          } else {
            console.log("停止频道搜索失败");
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          this.loading.close();
          this.loading = null;
          // loading.close();
      });
    },
            getChannelInfo(data,boardId){
      console.log("获取最新频道接口请求参数:"+JSON.stringify(data));
           this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 正在更新最新搜索到的频道信息,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      getChannelInfo(data).then(res =>{
        if (res.code == 200) {
            console.log("最新频道信息更新完成,开始进行配置默认频道");
            this.setChannelInfoRestart(data,boardId);
          } else {
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          // this.loading.close();
          // this.loading = null;
          // loading.close();
      });
    },
            setChannelInfoRestart(data,boardId){
      console.log("分发默认频道接口请求参数:"+JSON.stringify(data));
              this.loading = this.$loading({
          lock: true,
          text: '直播板卡'+boardId+' 正在分发默认频道,请持续等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      setChannelInfoRestart(data).then(res =>{
        if (res.code == 200) {
            console.log("频道分发成功,一键配置功能已完成");
            this.$modal.alertSuccess(res.data.msg || '配置成功');
          } else {
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          this.loading.close();
          this.loading = null;
          // loading.close();
      });
    },

    clearAgainScanClick(){
      const loading = this.$loading({
          lock: true,
          text: '正在进行一键配置功能,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        // clearAgainScan().then(response => {
        //   console.log("一键配置频道结果: "+JSON.stringify(response));
        //   loading.close();
        // });
          // 设置超时时间，这里设置为 5000 毫秒（即 5 秒），你可以按需调整
    // const timeout = 5000;  //至少4分钟
      const timeout = 300000; //==>300秒==>5分钟
      const timeoutPromise = new Promise((_, reject) => {
          setTimeout(() => {
              reject(new Error('请求超时'));
          }, timeout);
      });

      Promise.race([clearAgainScan(), timeoutPromise])
      .then(response => {
            console.log("一键配置频道结果: " + JSON.stringify(response));
            this.$modal.alertError(response.msg);
            loading.close();
        })
      .catch(error => {
            console.error('请求出错:', error.message);
            this.$modal.alertError(error.msg);
            loading.close();
            // 可以在这里添加处理超时或其他错误的逻辑
        });
    },
    /** 查询频道管理列表 */
    getList() {
      this.loading = true;
      listChannelSearch().then(response => {
        console.log("频道搜索: "+JSON.stringify(response));
      });
    },
    clearScan () {
      MessageBox.confirm('当前操作会清除已搜索数据，慎重操作', '系统提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
        this.resetProgramDbsData({
          "satellite": this.satelliteType,
          "board": this.board,
        });
      }).catch(_ => { })
    },

    resetProgramDbsData(data){
      console.log("清除频道接口请求参数:"+JSON.stringify(data));
              const loading = this.$loading({
          lock: true,
          text: '正在进行清除该直播板卡分发的频道,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      resetProgramDbsData(data).then(res =>{
        if (res.code == 200) {
            this.resetSetPrfData(data);
            // this.$message({ message: res.msg, type: 'success' })
            // this.$message({ message: "频道已清除，请到频道搜索页面重新开始搜索", type: 'success' })
            // setTimeout("location.reload();", 1000);
          } else {
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道接口响应:"+error);
      }).finally(() =>{
          loading.close();
      });
    },

    resetSetPrfData(data){
      console.log("清除频道设置接口请求参数:"+JSON.stringify(data));
      resetSetPrfData(data).then(res =>{
        if (res.code == 200) {
            this.$message({ message: "频道已清除，请到频道搜索页面重新开始搜索", type: 'success' })
            // setTimeout("location.reload();", 1000);
          } else {
            this.$message({ message: res.msg, type: 'error' })
          }
      }).catch(error =>{
        console.log("清除频道设置接口响应:"+error);
        return
      });
    },

    startChannelScanData(data,loading){
        console.log("频道搜索开始接口请求参数:"+JSON.stringify(data));
          startChannelScanData(data).then(res =>{
            console.log("频道搜索开始接口响应 : "+JSON.stringify(res));
            if (res.code == 200) {
              console.log('start scan '+res.msg+"========="+this.isRequesting);
              this.$message({ message: '启动搜索,请等待', type: 'success' })
              var ttt = res.msg;
              if(this.isRequesting){
                return;// 如果正在请求，直接返回，不发起新请求
              }
              clearInterval(this.timerScan)


              this.timerScan = setInterval(async () => {
                console.log("判断是否还在请求中: "+this.isRequesting);
                if(this.isRequesting){
                  console.log("上一个请求还未完成,暂时不发送请求");
                  return;
                }
                this.isRequesting = true;
                console.log("上一个请求已完成,开始重复发送请求: "+this.isRequesting);

                const controller = new AbortController();
                const signal = controller.signal;

                // 设置请求超时时间为 20 秒
                const timeoutId = setTimeout(() => {
                    controller.abort();
                }, 20000);

                try{

                  const res = await m3GetService({ "url": ttt, "satellite": this.satelliteType }, { signal });
                  clearTimeout(timeoutId); // 清除超时定时器
                  console.log("scan m3GetService接口响应:" + JSON.stringify(res));
                  if (res.data === 1) {
                      // 继续查询
                      console.log("继续查询:" + this.isRequesting);
                  } else if(res.data === 0){
                      console.log("停止查询:"+ this.isRequesting+"========="+JSON.stringify(res));
                      // 停止搜索
                      this.stopChannelScanData({ "board": this.board }, loading);
                      clearInterval(this.timerScan);
                      this.timerScan = null;
                  }else{
                      console.log("查询过程中出现异常,返回状态不对========"+JSON.stringify(res));
                      this.$message({ message: "频道搜索失败,请检查环境稍后重试", type: 'success' })
                      // 停止搜索
                      this.stopChannelScanData({ "board": this.board }, loading);
                      clearInterval(this.timerScan);
                      this.timerScan = null;
                      loading.close();
                  }
                }catch(error){
                  console.log("重复发送请求出现异常:"+JSON.stringify(error));

                  if (error.name === 'AbortError') {
                     console.log("搜索接口请求超时");
                  } else {
                      console.log("搜索接口响应:" + error);
                  }
                  this.$message({ message: "频道搜索失败,请检查环境稍后重试", type: 'success' })
                  this.stopChannelScanData({ "board": this.board }, loading);
                  clearInterval(this.timerScan);
                  this.timerScan = null;
                  loading.close();
                }finally{
                   // 确保无论请求成功还是失败，this.isRequesting 都会被重置为 false
                  this.isRequesting = false;
                  console.log("请求已完成,更新请求标志: " + this.isRequesting);
                }
              }, 2000)
            } else {
                this.stopChannelScanData({"satellite": this.satelliteType },loading);
                console.log("搜索接口响应:"+error);
                    clearInterval(this.timerScan)
                    this.timerScan = null;
                    this.isRequesting = false;
                    loading.close();
            }
      }).catch(error =>{
        console.log("频道搜索开始接口响应:"+error);
        loading.close();
        return
      });
    },

    //查询接口
    m3GetService(data,loading){
      console.log("=================查询接口==============="+JSON.stringify(data));
      m3GetService(data).then(res => {
        console.log("scan m3GetService接口响应数据:"+JSON.stringify(res));
        // if(res.data == 1){
        //   //继续查询
        //   this.m3GetService(data,loading);
        //   return
        // }else if(res.data == 0){
        //   //停止搜索
        //   console.log("停止发送数据");
        //   this.stopChannelScanData({"board": this.board },loading);
        //   clearInterval(this.timerScan)
        //   loading.close();
        //   return
        // }else{
        //   this.$message({ message: "频道搜索失败,请检查环境稍后重试", type: 'success' })
        //   console.log("循环搜索接口状态有误:"+JSON.stringify(res));
        //   clearInterval(this.timerScan)
        //   loading.close();
        //   return
        // }
      }).catch(error =>{
          console.log("搜索接口响应:"+error);
          clearInterval(this.timerScan)
          loading.close();
          return
      });
    },

    stopChannelScanData(data,loading){
      console.log("停止开始搜索参数================:"+JSON.stringify(data));
      stopChannelScanData(data).then(res => {
      console.log("停止搜索结果====================:"+JSON.stringify(res));
        if(res.code == 200){
          this.$message({ message: '搜索结束,请到输出设置查看搜索结果~', type: 'success' })
          loading.close();
          console.log('stop scan', res)
        }else{
          loading.close();
          console.log('stop scan', res)
        }
      }).catch(error =>{
          console.log("搜索结束接口响应:"+error);
          clearInterval(this.timerScan)
          loading.close();
          return
      });
    },

    scanWeixing () {
      const loading = this.$loading({
          lock: true,
          text: '直播板卡'+this.board+'频道搜索中,请等待...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      var tmp = 17
      if (this.jhfs == '左旋') {
        tmp = 2
      } else {
        tmp = 3
      }
      this.startChannelScanData({
        "frequency": Number(this.pl),
        "symbolRate": Number(this.fhl),
        "polarization": Number(tmp),
        "board": this.board,
      },loading);
    },

    getPro () {
      getTunerInfo({ satellite_token: this.token }).then(res => {
            // console.log('b', res)
            console.log('bbbbbbbbbbbb', res.data.info[0])
              var tmp = res.data.info[0]
              this.signalLevel = tmp.signalLevel * 2 / 1
              this.signalQuality = tmp.signalQuality * 2 / 1
              var tmp1 = res.data.info[1]
              this.signalLevel1 = tmp1.signalLevel * 2 / 1
              this.signalQuality1 = tmp1.signalQuality * 2 / 1
          })
      this.timers = setInterval(()=>{
        getTunerInfo({ satellite_token: this.token }).then(res => {
            // console.log('b', res)
            console.log('bbbbbbbbbbbb', res.data.info[0])
              var tmp = res.data.info[0]
              this.signalLevel = tmp.signalLevel * 2 / 1
              this.signalQuality = tmp.signalQuality * 2 / 1
              var tmp1 = res.data.info[1]
              this.signalLevel1 = tmp1.signalLevel * 2 / 1
              this.signalQuality1 = tmp1.signalQuality * 2 / 1
          })
      },2000)
    },
    changeNumB (val) {
      console.log(val)
      if (val == 'next') {
        if (this.numB == this.numbersB.length - 1) {
          this.numB = 0
          return
        }
        this.numB++
      }
      if (val == 'last') {
        if (this.numB == 0) {
          this.numB = this.numbersB.length - 1
          return
        }
        this.numB--
      }
    },
    changeNum (val) {
      console.log(val)
      if (val == 'next') {
        if (this.num == this.numbers.length - 1) {
          this.num = 0
          return
        }
        this.num++
      }
      if (val == 'last') {
        if (this.num == 0) {
          this.num = this.numbers.length - 1
          return
        }
        this.num--
      }
    },
    changeball (val) {
      console.log(val)
      if (val == 'next') {
        if (this.ball == this.balls.length - 1) {
          this.ball = 0
          return
        }
        this.ball++
      }
      if (val == 'last') {
        if (this.ball == 0) {
          this.ball = this.balls.length - 1
          return
        }
        this.ball--
      }
    },
  },
  created () {
    for (var i = 0; i < 21; i++) {
      this.numbers.push({ name: (i + 1) + '', key: i })
    }
    for (var i = 0; i < 23; i++) {
      this.numbersB.push({ name: (i + 1) + '', key: i })
    }
  },
}
</script>
<style scoped>
.title {
  width: 100px;
  font-size: 14px;
}

.boxCon {
  width: 200px;
  background-color: antiquewhite;
  height: 25px;
}

.boxSear {
  width: 220px;
  background-color: antiquewhite;
  height: 25px;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
}

.btnImg {
  width: 15px;
  height: 15px;
  margin-top: 5px;
  cursor: pointer;
}

.fontShow {
  margin-top: 8px;
  font-size: 12px;
}

.disBox {
  display: flex;
}
.disBox1 {
  display: flex;
  margin-bottom: 10px;
}

.progress {
  height: 50px;
  /* background-color: antiquewhite; */
}

.proBox {
  width: 200px;
  height: 25px;
  border: 1px solid antiquewhite;
}

.fontShowBox {
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

.proLen {
  font-size: 18px;
  font-weight: bold;
  margin: 1px 8px;
}

.backWork {
  width: 100%;
  height: 60vh;
}
</style>

